package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetMealDishMapper {
    /**
     * 根据菜品id查询对应套餐
     * @param ids
     * @return
     */
    List<Long> getByDishIds(List<Long> ids);

    void insert(List<SetmealDish> setmealDishes);

    @Select("select * from setmeal_dish where setmeal_id =#{id}")
    List<SetmealDish> getBymealId(Long id);

    /**
     * 根据套餐id删除套餐和菜品关联数据
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id=#{setmealId}")
    void deleteByMealId(Long setmealId);

    /**
     * 根据菜皮id删除套餐和菜品的关联数据
     * @param dishId
     */
    @Delete("delete from setmeal_dish where dish_id = #{dishId}")
    void deleteByDishId(Long dishId);
}
